1 using UnityEngine;
2 using
System.Collections;
3
4 public
class OnClickInstantiate : MonoBehaviour
5 {
6     
public GameObject Prefab;
7     
public int InstantiateType;
8     
private string[] InstantiateTypeNames = {"Mine", "Scene"};
9
10     
public bool showGui;
11
12     
void OnClick()
13     {
14         
if (PhotonNetwork.connectionStateDetailed != PeerState.Joined)
15         {
16             
// only use PhotonNetwork.Instantiate while in a room.
17             
return;
18         }
19
20         
switch (InstantiateType)
21         {
22             
case 0:
23                 PhotonNetwork.Instantiate(Prefab.name, InputToEvent.inputHitPos +
new Vector3(0, 5f, 0), Quaternion.identity, 0);
24                 
break;
25             
case 1:
26                 PhotonNetwork.InstantiateSceneObject(Prefab.name, InputToEvent.inputHitPos +
new Vector3(0, 5f, 0), Quaternion.identity, 0, null);
27                 
break;
28         }
29     }
30
31     
void OnGUI()
32     {
33         
if (showGui)
34         {
35             GUILayout.BeginArea(
new Rect(Screen.width - 180, 0, 180, 50));
36             InstantiateType = GUILayout.Toolbar(InstantiateType, InstantiateTypeNames);
37             GUILayout.EndArea();
38         }
39     }
40
41
42 }


only use PhotonNetwork.Instantiate while in a room.




Trò chơi Tic-Tac-Toe, game đánh caro full source code 53.503 lượt xem

Gõ tìm kiếm nhanh...